package br.ita.doacoes.view.cadastrofamilia;

import java.util.List;

import javax.swing.DefaultComboBoxModel;

import br.ita.doacoes.core.cadastrofamilia.dao.DAO;
import br.ita.doacoes.core.cadastrofamilia.dao.GenericDAOJPA;
import br.ita.doacoes.domain.cadastrofamilia.Familia;
import br.ita.doacoes.view.cadastrofamilia.refresher.Refreshable;
import br.ita.doacoes.view.cadastrofamilia.refresher.Refresher;



public class FamiliaCombo extends DefaultComboBoxModel implements Refreshable {

	DAO dao = new GenericDAOJPA(Familia.class, "doacoes");
	
	
	public FamiliaCombo() {
		
		refresh();
		Refresher.add(this);

	}

	public void refresh() {
		//List<Familia> lista = dao.getList();
		List<Familia> lista = dao.getList();
		removeAllElements();	
		for (Familia obj : lista) {
		
		//FamiliaSingleton f= FamiliaSingleton.getInstance();	
		//	if(obj.getIdFamilia()== f.getFamilia().getIdFamilia())
		//	if(f.getFamilia()!=null)	
			addElement(obj);
			
		/*	else
				if(obj.getIdFamilia()== f.getFamilia().getIdFamilia())
					addElement(obj);
			
				//System.out.printf("\nID OBJ CORRENTE: %d \t ID f.getFamilia: %d ", obj.getIdFamilia(), f.getFamilia().getIdFamilia()); */
		}
		
		
	}
}

